home *** CD-ROM | disk | FTP | other *** search
/ Champak 140 / (Vol 140) Sep 19 2011.iso / Games / theLifeArk.swf / scripts / __Packages / prop / cloud.as next >
Encoding:
Text File  |  2011-09-19  |  5.7 KB  |  247 lines

  1. class prop.cloud extends MovieClip
  2. {
  3.    var runSta;
  4.    var switchOn;
  5.    var eleQtt;
  6.    var eleQttMax;
  7.    var waterQtt;
  8.    var waterQttMax;
  9.    var moveDrct;
  10.    var moveBoundary;
  11.    var moveSpeed;
  12.    var tarXTask;
  13.    var pwOk;
  14.    var onEnterFrame;
  15.    var tarX;
  16.    var ctt;
  17.    var rope;
  18.    function cloud()
  19.    {
  20.       super();
  21.       this.runSta = "rest";
  22.       this.switchOn = false;
  23.       this.eleQtt = 0;
  24.       this.eleQttMax = 1000;
  25.       this.waterQtt = 0;
  26.       this.waterQttMax = 1500;
  27.       this.moveDrct = "left";
  28.       this.moveBoundary = new Array(200,700);
  29.       this.moveSpeed = 2;
  30.       this.setOEF(true);
  31.       this.tarXTask = "none";
  32.       this.pwOk = false;
  33.    }
  34.    function setOEF(p)
  35.    {
  36.       if(p)
  37.       {
  38.          this.onEnterFrame = this.OEF;
  39.       }
  40.       else
  41.       {
  42.          this.onEnterFrame = null;
  43.       }
  44.    }
  45.    function setTask(pTask, pX)
  46.    {
  47.       this.tarXTask = pTask;
  48.       this.tarX = pX;
  49.       this.runSta = "moveToP";
  50.    }
  51.    function disapear()
  52.    {
  53.       this.runSta = "disapear";
  54.    }
  55.    function setChargeOver()
  56.    {
  57.       this.ctt.gotoAndStop("fullPower");
  58.       this.rope.gotoAndStop("off");
  59.       this.runSta = "rest";
  60.       this.switchOn = false;
  61.       this.tarXTask = "none";
  62.       _global.scene.cloudPw = true;
  63.    }
  64.    function setMetalPotOver()
  65.    {
  66.       this.ctt.gotoAndStop("rest");
  67.       this.rope.gotoAndStop("on");
  68.       this.runSta = "moveSelf";
  69.       this.switchOn = true;
  70.       this.tarXTask = "none";
  71.       _global.scene.metalPot = true;
  72.       _global.scene.cloudPw = false;
  73.    }
  74.    function setFullWater()
  75.    {
  76.       _global.scene.pot.steamBtn.enabled = false;
  77.       _global.scene.doorBtn.enabled = true;
  78.       _global.scene.doorBtn._y = _global.scene.steamBtn._y;
  79.       _global.scene.steamBtn.unloadMovie();
  80.       _global.scene.fullWater = true;
  81.       this.rope.gotoAndStop("off");
  82.       this.runSta = "rest";
  83.       this.switchOn = false;
  84.       this.tarXTask = "none";
  85.    }
  86.    function setRainOver()
  87.    {
  88.       _global.scene.rainOver = true;
  89.       _global.scene.stepBtn.enabled = true;
  90.       this.ctt.gotoAndStop("rest");
  91.       this.rope.gotoAndStop("on");
  92.       this.runSta = "moveSelf";
  93.       this.switchOn = true;
  94.       this.tarXTask = "none";
  95.    }
  96.    function cutTreesOver()
  97.    {
  98.       this.ctt.gotoAndStop("rest");
  99.       this.rope.gotoAndStop("off");
  100.       this.runSta = "rest";
  101.       this.switchOn = false;
  102.       this.tarXTask = "none";
  103.       _global.scene.cloudPw = "usedByTrees";
  104.       _global.scene.trees.runSta = "dead";
  105.    }
  106.    function OEF()
  107.    {
  108.       switch(this.runSta)
  109.       {
  110.          case "rest":
  111.             break;
  112.          case "moveSelf":
  113.             this.moveStep();
  114.             break;
  115.          case "moveToP":
  116.             this.moveToStep();
  117.             break;
  118.          case "disapear":
  119.             this.disapearStep();
  120.       }
  121.    }
  122.    function moveStep()
  123.    {
  124.       switch(this.moveDrct)
  125.       {
  126.          case "left":
  127.             if(this._x > this.moveBoundary[0])
  128.             {
  129.                this._x -= this.moveSpeed;
  130.             }
  131.             else
  132.             {
  133.                this.moveDrct = "right";
  134.             }
  135.             break;
  136.          case "right":
  137.             if(this._x < this.moveBoundary[1])
  138.             {
  139.                this._x += this.moveSpeed;
  140.             }
  141.             else
  142.             {
  143.                this.moveDrct = "left";
  144.             }
  145.       }
  146.    }
  147.    function moveToStep()
  148.    {
  149.       var _loc2_ = this.tarX - this._x;
  150.       if(Math.abs(_loc2_) > this.moveSpeed)
  151.       {
  152.          if(_loc2_ > 0)
  153.          {
  154.             this._x += 1.5 * this.moveSpeed;
  155.          }
  156.          else
  157.          {
  158.             this._x -= 1.5 * this.moveSpeed;
  159.          }
  160.       }
  161.       else
  162.       {
  163.          this._x = this.tarX;
  164.          this.doTask();
  165.       }
  166.    }
  167.    function doTask()
  168.    {
  169.       switch(this.tarXTask)
  170.       {
  171.          case "chargePower":
  172.             _global.scene.plugAni.setAni(["play","extend"]);
  173.             this.runSta = "chargePower";
  174.             break;
  175.          case "chargeWater":
  176.             trace("doTask chargeWater");
  177.             _global.ctn.sndCtrl.playSound("snd_breath");
  178.             this.ctt.gotoAndStop("collectingWater");
  179.             this.runSta = "collectingWater";
  180.             break;
  181.          case "cutStone":
  182.             this.ctt.gotoAndStop("cutting");
  183.             this.runSta = "cutting";
  184.             break;
  185.          case "raining":
  186.             this.runSta = "raining";
  187.             this.ctt.gotoAndStop("raining");
  188.             _global.scene.rainAni._visible = true;
  189.             _global.scene.rainAni.play();
  190.             break;
  191.          case "cutTrees":
  192.             this.runSta = "cutTrees";
  193.             this.ctt.gotoAndStop("cutTrees");
  194.       }
  195.    }
  196.    function ropePrs()
  197.    {
  198.       this.switchOn = !this.switchOn;
  199.       if(this.switchOn)
  200.       {
  201.          this.activeMove();
  202.       }
  203.       else
  204.       {
  205.          this.disableMove();
  206.       }
  207.    }
  208.    function activeMove()
  209.    {
  210.       if(this.tarXTask == "none")
  211.       {
  212.          this.runSta = "moveSelf";
  213.       }
  214.       else if(Math.abs(this._x - this.tarX) < this.moveSpeed)
  215.       {
  216.          switch(this.tarXTask)
  217.          {
  218.             case "chargePower":
  219.             case "chargeWater":
  220.             case "cutStone":
  221.             case "raining":
  222.          }
  223.       }
  224.       else
  225.       {
  226.          this.runSta = "moveSelf";
  227.       }
  228.    }
  229.    function disableMove()
  230.    {
  231.       this.runSta = "rest";
  232.    }
  233.    function disapearStep()
  234.    {
  235.       this.ropePrs = null;
  236.       if(this._y > -150)
  237.       {
  238.          this._y -= this.moveSpeed;
  239.       }
  240.       else
  241.       {
  242.          this.runSta = "gameWin";
  243.          this.setOEF(false);
  244.       }
  245.    }
  246. }
  247.